﻿using System.Xml;
using System.Web.Mvc;
using System.ServiceModel.Syndication;

namespace WeBlog.ActionResults {
	public class AtomActionResult : ActionResult {
		public SyndicationFeed Feed { get; set; }

		public override void ExecuteResult(ControllerContext context ) {

            context.HttpContext.Response.ContentType = "application/atom+xml";
            Atom10FeedFormatter atomFormatter = new Atom10FeedFormatter(Feed);

            using (XmlWriter writer = XmlWriter.Create(context.HttpContext.Response.Output))
            {
                atomFormatter.WriteTo(writer);
            }
        }
	}
}